<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>侧边栏动画</title>
    <style>
        a {
            padding: 10px;
            text-decoration: none;
            display: block;
            color: #818181;
        }

        .closebtn {
            padding: 0;
            font-size: 25px;
            position: absolute;
            z-index: 3;
            right: 9px;
        }

        .sidenav {
            position: absolute;
            background: black;
            top: 0;
            bottom: 0;
            left: 0;
            /* width: 300px; */
            overflow: hidden;
            width: 0;
            transition: all 1s;
        }

        a:hover {
            color: #ffffff;
        }
    </style>
</head>

<body>
    <div id="mySidenav" class="sidenav">
        <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
        <a href="#">About</a>
        <a href="#">Services</a>
        <a href="#">Clients</a>
        <a href="#">Contact</a>
    </div>

    <h2>侧边栏动画实例</h2>
    <p>点击以下菜单图标打开侧边栏</p>
    <span style="font-size:30px;cursor:pointer" onclick="openNav()">&#9776; 打开</span>
    <script>
        let dv = document.getElementById('mySidenav')
        function openNav() {

            dv.style.width = "100%"
        }
        function closeNav() {
            dv.style.width = ""
        }
    </script>
</body>

</html>